from pathlib import *
from os import path
import fnmatch
import time
import fileinput
import linecache

# p=PurePath('filedemo.txt')
# print(type(p))
#
# p=PurePosixPath('filedemo.txt')
# print(p)
#
# p=Path('.')
# for file in p.iterdir():
#     if(fnmatch.fnmatch(file,'*.txt')):
#         print(file)
#
# p=Path('filedemo.txt')
# p.write_text('''这是文件读写的实例''',encoding='UTF-8')
# print(p.read_text(encoding='UTF-8'))
# print(p.read_bytes())
#
# print(path.isdir('filedemo.txt'))
# print(path.isfile('filedemo.txt'))
# print(path.abspath('filedemo.txt'))
# print(time.ctime(path.getctime('filedemo.txt')))

# f=open('filedemo.txt')
# print(f.name,f.closed,f.encoding,f.mode)

# f=open('filedemo.txt','r',True,'UTF-8')
# while True:
#     s=f.read(3)
#     if not s:
#         break
#     print(s)
# f.close()

# f=open('filedemo.md','r+',10,'UTF-8')
# f.write("这是第二个文件读写实例")
# f.flush()
# f.seek(0,0)
#
# while True:
#     s=f.read(1)
#     if not s:
#         break
#     print(s)
# f.close()

# f=open('filedemo.txt','w')
# f.write("这是文件IO实例1")
# f1=open('filedemo.md','w')
# f1.write('这是文件IO实例2')
# f.close()
# f1.close()
# for line in fileinput.input(files=('filedemo.txt','filedemo.md')):
#     print(fileinput.filename(),fileinput.filelineno(),line,end='\n')
# fileinput.close()

# with fileinput.input(files=('filedemo.txt','filedemo.md')) as f:
#     for line in f:
#         print(line)

print(linecache.getline('first.py',3))


